package approval.dao;

import java.sql.ResultSet;
import java.util.ArrayList;

import model.pojo.Languages;
import models.util.MySqlDataAccessHelper;

public class LangDAO {

	public ArrayList<Languages> allLang() {
		ArrayList<Languages> result = new ArrayList<Languages>();
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		mysql.open("admin");
		try {

			String sql = "select * from configlang";
			ResultSet rs = mysql.executeQuery(sql);

			String vn = "";
			String en = "";
			String kr = "";
			while (rs.next()) {
				String ID = rs.getString("ID");
				if (rs.getString("VN") != null)
					vn = rs.getString("VN");
				if (rs.getString("EN") != null)
					en = rs.getString("EN");
				if (rs.getString("KR") != null)
					kr = rs.getString("KR");
				Languages l = new Languages(ID, vn, en, kr);
				result.add(l);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				mysql.close();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		// result.toArray(new String[result.size()]);
		return result;
	}
}
